package com.ruoyi.web.controller.tool;

import com.ruoyi.web.controller.tool.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/email")
public class EmailController {
    @Autowired
    private EmailService emailService;
    @RequestMapping("/send")
    public String sendEmail(@RequestParam("to") String to,@RequestParam("subject")String subject,@RequestParam("text") String text) {
        System.out.println("发送邮件");
        System.out.println("目标邮箱"+to+"标题"+subject+"内容"+text);
        try {
            emailService.sendEmail(to, subject, text);
            return "发送成功";
        } catch (Exception e) {
            e.printStackTrace();
            return "发送失败";
        }
    }
}
